From 479c341545bb5e4f04dbbd2df6fa9318bdfb9888 Mon Sep 17 00:00:00 2001 From: Mario Sanchez Prada Date: Mon, 4 Jun 2018 17:27:45 +0100 Subject: [PATCH] application: Use the new API to get the startup notification ID The DESKTOP_STARTUP_ID gets cleared early after the process is spawned, meaning that it's too late at add_platform_data() to pick it up and send it over to the primary instance, as it will be always unset at that point. To solve this, we use the new gdk_display_get_startup_notification_id() method to pull the startup notification ID for the application, if present, out of the display and pass it over to that primary instance. https://gitlab.gnome.org/GNOME/gtk/issues/1084 --- gtk/gtkapplication.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/gtk/gtkapplication.c b/gtk/gtkapplication.c index 91b14af558..dd2aeb038c 100644 --- a/gtk/gtkapplication.c +++ b/gtk/gtkapplication.c @@ -329,7 +329,7 @@ static void gtk_application_add_platform_data (GApplication *application, GVariantBuilder *builder) { - const gchar *startup_id; + GdkDisplay *display; /* This is slightly evil. * @@ -338,11 +338,16 @@ gtk_application_add_platform_data (GApplication *application, * * So we do all the things... which currently is just one thing. */ - startup_id = getenv ("DESKTOP_STARTUP_ID"); + display = gdk_display_get_default (); + if (display) + { + const gchar *startup_id; - if (startup_id && g_utf8_validate (startup_id, -1, NULL)) - g_variant_builder_add (builder, "{sv}", "desktop-startup-id", - g_variant_new_string (startup_id)); + startup_id = gdk_display_get_startup_notification_id (display); + if (startup_id && g_utf8_validate (startup_id, -1, NULL)) + g_variant_builder_add (builder, "{sv}", "desktop-startup-id", + g_variant_new_string (startup_id)); + } } static void -- 2.30.2